import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router';
import Home from '../views/Home.vue';

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/Login/index.vue'),
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});
// router.beforeEach((to, from, next) => {
//   const whiteList = ['/login'];
//   const user = useUserStore();
//   if (user.token) {
//     if (to.path.includes('/login')) {
//       // 如果在登录页且 Token 未过期，重定向到首页
//       if (!storage.isExpired('token')) {
//         next('/');
//         return;
//       } else {
//         next();
//       }
//     }
//   } else {
//     user.clear();
//     if (!whiteList.includes(to.path)) {
//       next('/login');
//       return;
//     }
//   }
//   next();
// });
export default router;
